package com.yy.tech.data.provider.model;

import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author yy
 * @date 2022/4/19
 * @description: TODO
 */
public class SecretRules {
    private List<SecretRule> rules;

    public List<SecretRule> getRules() {
        return rules;
    }

    public void setRules(final List<SecretRule> rules) {
        this.rules = rules;
    }

    public SecretRule findRule(FindCondition condition){
        if (!CollectionUtils.isEmpty(rules)){
            return rules.stream().filter(r->r.match(condition)).findFirst().orElse(null);
        }
        return null;
    }
}
